﻿using System;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Imaging;

namespace MangaReader
{
	/// <summary>
	/// Nothing special - window with fields, necessary to add new manga project.
	/// </summary>
	public partial class AddMangaWindow : Window
	{
		public string coverPath;
		public AddMangaWindow()
		{
			coverPath = string.Empty;
			InitializeComponent();
		}

		private void addButton_Click(object sender, RoutedEventArgs e)
		{
			if ((coverImage.Source == null) || (coverPath == string.Empty))
				System.Windows.Forms.MessageBox.Show("Please, select manga cover image!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
			else
				Close();
		}

		private void openMangaFolderButton_Click(object sender, RoutedEventArgs e)
		{
			var d = new FolderBrowserDialog();
			if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				pathBox.Text = d.SelectedPath;
			}
		}

		private void browserCoverButton_Click(object sender, RoutedEventArgs e)
		{
			var d = new OpenFileDialog();
			d.Filter = "Image Files (*.jpeg,*.jpg,*.png,*.bmp)|*.jpg;*.png;*.jpeg;*.bmp";
			if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				coverPath = d.FileName;
				coverImage.Source = new BitmapImage(new Uri(coverPath));
			}
		}
	}
}
